from django.shortcuts import render

# Create your views here.
from django.views import View

from contents.models import ContentsLeibie
from goods.utils import get_categories


class IndexView(View):
    def get(self, request):
        categories = get_categories()

        contents = ContentsLeibie.objects.all()

        dict = {}

        for cat in contents:
            dict[cat.key] = cat.content_set.filter(status=True).order_by('sequence')

        context = {'categories': categories,
                   'contents': dict}

        return render(request, 'index.html', context)


# class TiaozhuanView(View):
#     def get(self, request):
#
#         return render(request, 'index.html')